package app.Disthanitian.thaistyle.EmerMez;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class SendSMS extends Activity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sendsms);
		//sendSMS();
		//sendLongSMS();

		Button send = (Button) findViewById(R.id.SendSMS);
		
		

		
		  send.setOnClickListener(new OnClickListener() {
		  
		  @Override public void onClick(View arg0) { Intent smsIntent = new
		 
		 Intent(Intent.ACTION_VIEW);
		  
		  smsIntent.putExtra("sms_body", "Hello World!");
		  smsIntent.putExtra("address", "0123456789");
		  smsIntent.setType("vnd.android-dir/mms-sms");
		  
		  startActivity(smsIntent);
		  
		  } });
		
	}

	public void sendSMS() {
		String phoneNumber = "5556";
		String message = "Nest!";

		SmsManager smsManager = SmsManager.getDefault();
		smsManager.sendTextMessage(phoneNumber, null, message, null, null);
		
		Toast.makeText(SendSMS.this,"Send SMS Complete",Toast.LENGTH_LONG).show();
	}
	
	public void sendLongSMS() {
		 
	    String phoneNumber = "5556";
	    String message = "Hello World! Now we are going to demonstrate " + 
	            "how to send a message with more than 160 characters from your Android application. " +
	    		"www.google.co.th";

	    SmsManager smsManager = SmsManager.getDefault();
	    ArrayList<String> parts = smsManager.divideMessage(message); 
	    smsManager.sendMultipartTextMessage(phoneNumber, null, parts, null, null);
	    
	    Toast.makeText(SendSMS.this,"Send SMS Complete",Toast.LENGTH_LONG).show();
	}

}
